package com.oracle.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.oracle.model.User;
import com.oracle.service.CarService;
import com.oracle.service.impl.CarServiceImpl;

/**
 * ȡ�û���Ϣ��Servlet
 * 
 * @author Administrator
 *
 */
@WebServlet("/userServlet")
public class UserServlet extends HttpServlet {
	
	 CarService carService = new CarServiceImpl();
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		 response.setCharacterEncoding("UTF-8");
	        response.setContentType("application/json; charset=utf-8");
	        List<Object> list = carService.getCarList();
	        PrintWriter out = null;
	        System.out.println("list:"+list.toString());
	        try {
	            out = response.getWriter();
	            out.write(list.toString());
	        } catch (Exception e) {
	            System.out.println(e.getMessage());
	        }
	        out.flush();
	        out.close();

	}
}
